import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'index.dart';

class GuidePage extends GetView<GuideController> {
  const GuidePage({super.key});

  // 主视图
  Widget _buildView() {
    final poiList = controller.poiList;
    return ListView.separated(
      itemCount: poiList.length,
      separatorBuilder: (BuildContext context, int index) {
        return Divider();
      },
      itemBuilder: (BuildContext context, int index) {
        final model = poiList[index];
        return ListTile(
          title: Text(model),
          subtitle: Text(
            model == controller.originalPoi ? "原点" : "",
            style: TextStyle(fontSize: 15, color: Colors.red),
          ),
          trailing: Icon(Icons.arrow_forward_ios),
          onTap: () {
            controller.onTap(model);
          },
        );
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<GuideController>(
      init: GuideController(),
      id: "guide",
      builder: (_) {
        return Scaffold(
          appBar: AppBar(title: const Text("guide")),
          body: SafeArea(child: _buildView()),
        );
      },
    );
  }
}
